/*
 * FileName: LoginService.java
 *
 *  
 */
package com.mrc.core.utils;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import com.mrc.core.model.SysUser;
import com.mrc.core.service.SysUserService;

/**
 * <p>
 * Description:  登录工具类
 * </p>
 *
 * @author Mrc
 * @version 4.1

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2016-11-19 上午11:39:12          Mrc        4.1         To create
 * </p>
 *
 * @since 
 * @see     
 */
public class LoginUtils {
    @Autowired
    private SysUserService sysUserService;
    private static LoginUtils loginUtils;

    public void setUserInfo(SysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

    @PostConstruct
    public void init() {
        loginUtils = this;
        loginUtils.sysUserService = this.sysUserService;
    }

    public static SysUser getLoginUser(HttpServletRequest requset) {
        String userName = requset.getParameter("userName");
        String pwd = requset.getParameter("pwd");

        if (userName == null || pwd == null)
            return null;

        return loginUtils.sysUserService.findByMobile(userName);
    }

}
